package com.gxa.service.investment.impl;

import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.gxa.dto.investmentDto.IntentionAgreementDto;
import com.gxa.dto.investmentDto.IntentionAgreementResult;
import com.gxa.entity.investment.Company;
import com.gxa.entity.investment.IntentionAgreement;
import com.gxa.entity.investment.IntentionRegister;
import com.gxa.entity.investment.InvestmentPlan;
import com.gxa.mapper.investment.IntentionAgreementMapper;
import com.gxa.service.investment.IntentionAgreementService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.vo.investmentVo.IntentionAgreementVo;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 意向协议单 服务实现类
 * </p>
 *
 * @author yjl
 * @since 2022-10-17 03:04:36
 */
@Service
public class IntentionAgreementServiceImpl extends ServiceImpl<IntentionAgreementMapper, IntentionAgreement> implements IntentionAgreementService {
    @Autowired
    private IntentionAgreementMapper intentionAgreementMapper;

    @Override
    public void add(IntentionAgreement intentionAgreement) {
        intentionAgreementMapper.insert(intentionAgreement);
    }

    @Override
    //单表修改状态
    public void updateToState(Integer id, Integer state) {
        UpdateWrapper updateWrapper = new UpdateWrapper();
        updateWrapper.eq("id",id);
        updateWrapper.set("state", state);
        intentionAgreementMapper.update(null, updateWrapper);
    }

    @Override
    public IntentionAgreementResult queryById(Integer id) {
        return intentionAgreementMapper.queryById(id);
    }

    @Override
    public List<IntentionAgreementResult> listAll() {
        return intentionAgreementMapper.listAll();
    }

    @Override
    public PageInfo<IntentionAgreementResult> queryByIntentionAgreementDto(IntentionAgreementDto intentionAgreementDto, Integer pageNum, Integer pageSize) {
        Page<IntentionAgreementResult> page = PageHelper.startPage(pageNum,pageSize);
        List<IntentionAgreementResult> intentionAgreementResults = this.intentionAgreementMapper.queryByInvestmentPlanDto(intentionAgreementDto);
        PageInfo<IntentionAgreementResult> pageInfo = new PageInfo<>(intentionAgreementResults);

        return pageInfo;
    }

    //页面里的详情
    @Override
    public IntentionAgreementVo queryById02(Integer id) {

        return intentionAgreementMapper.queryById002(id);
    }

    @Override
    public List<IntentionRegister> queryAll() {
        List<IntentionRegister> list = this.intentionAgreementMapper.queryAll();
        return list;
    }
}
